package com.leyou.information.service;

import com.leyou.common.auth.pojo.UserHolder;
import com.leyou.information.UserInformation;
import com.leyou.information.mapper.InformationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class InformationService {
    @Autowired(required = false)
    private InformationMapper informationMapper;
    public Integer addUserInformation(UserInformation userInformation) {
        Long userId= UserHolder.getUserId();
        userInformation.setUserId(userId);
        Integer state = informationMapper.insert(userInformation);
        return state;
    }

    public UserInformation findUserInformationByUserId() {
        Long userId= UserHolder.getUserId();
        UserInformation userInformation=informationMapper.findUserInformationByUserId(userId);
        return userInformation;
    }

    public Integer findUserInformationStatus() {
        Long userId= UserHolder.getUserId();
        UserInformation userInformation=informationMapper.findUserInformation(userId);
        if(userInformation==null){
            return 1;
        }else{
            return 0;
        }
    }
}
